<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="5" :sm="8">
            <a-form-item :label="$t('日志内容')">
              <a-input :placeholder="$t('请输入')" v-model="queryParam.keyWord"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="10" :lg="11" :md="12" :sm="24">
            <a-form-item :label="$t('时间')">
              <a-date-picker
                :show-time="{ defaultValue: moment('00:00:00', 'HH:mm:ss') }"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                :placeholder="$t('请选择开始时间')"
                class="query-group-cust"
                v-model="queryParam.createTime_begin"
              ></a-date-picker>
              <span class="query-group-split-cust"></span>
              <a-date-picker
                :show-time="{ defaultValue: moment('23:59:59', 'HH:mm:ss') }"
                valueFormat="YYYY-MM-DD HH:mm:ss"
                :placeholder="$t('请选择结束时间')"
                class="query-group-cust"
                v-model="queryParam.createTime_end"
              ></a-date-picker>
            </a-form-item>
          </a-col>
          <a-col :md="5" :sm="8">
            <a-form-item :label="$t('登录账号')">
              <a-input :placeholder="$t('请输入')" v-model="queryParam.userid"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="5" :sm="8">
            <a-form-item :label="$t('用户姓名')">
              <a-input :placeholder="$t('请输入')" v-model="queryParam.username"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="8" :lg="9" :md="10" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">{{ $t('查询') }}</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">{{ $t('重置') }}</a-button>
              <a-button v-has="'SysLogController:export'" type="primary" icon="download" style="margin-left: 8px" :loading="exloading" @click="handleExportXls($t('登录日志'))">{{
                $t('导出')
              }}</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>
      <!-- <div style="color:orange;padding-bottom: 20px">{{$t("为了保证系统的运行性能，仅保留最近一个月内的登录日志。")}}</div> -->
      <a-table
        bordered
        ref="table"
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <!-- 字符串超长截取省略号显示-->
        <span slot="logContent" slot-scope="text">
          <j-ellipsis :value="text" :length="40"/>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->
  </a-card>
</template>

<script>
  import moment from 'moment'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import JEllipsis from '@/components/jeecg/JEllipsis'

  export default {
    name: "LogList",
    mixins:[JeecgListMixin],
    components: {
      JEllipsis
    },
    data () {
      return {
        moment,
        description: '登录日志管理页面',
        // 查询条件
        queryParam: {
          logType: '1',
          keyWord: '',
        },
        // 表头
        columns: [
          {
            title: this.$t('时间'),
            dataIndex: 'createTime',
            align:"center",
            //sorter: true
          },
          {
            title: this.$t('登录账号'),
            dataIndex: 'userid',
            align:"center",
            //sorter: true
          },
          {
            title: this.$t('用户姓名'),
            dataIndex: 'username',
            align:"center",
            //sorter: true
          },
          {
            title: 'IP',
            dataIndex: 'ip',
            align:"center",
            //sorter: true
          },
          {
            title: this.$t('日志内容'),
            align:"left",
            dataIndex: 'logContent',
            scopedSlots: { customRender: 'logContent' },
            //sorter: true
          },
        ],
        url: {
          list: "/sys/log/list",
          exportXlsUrl: "/sys/log/exportXls"
        },
      }
    },
    methods: {
      // 重置
      searchReset(){
        var that = this;
        var logType = that.queryParam.logType;
        that.queryParam = {}; //清空查询区域参数
        that.queryParam.logType = logType;
        that.loadData(that.ipagination.current);
      },
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>